<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class luongcanbo_Controller extends Controller {
    function __construct(){
        parent::__construct('quanlyluong', 'luongcanbo');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('quanlyluong', 'luongcanbo');
    }
    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_luongcanbo();
    }
    /****************************form canbo***********************/
    private function _save_filter(){
        $v_TYPE_filter = $this->get_post_var('hdn_TYPE_filter');
        $v_MA_DON_VI_filter = $this->get_post_var('cbx_MA_DON_VI_filter');
        $v_MA_TO_CHUYEN_MON_filter = $this->get_post_var('cbx_MA_TO_CHUYEN_MON_filter');
         //   echo '<script>alert("update type: '.$v_MA_TO_CHUYEN_MON_filter.'");</script>';
        if($v_TYPE_filter == ''){
           $v_TYPE_filter = 'MA_DON_VI';
           $v_MA_TO_CHUYEN_MON_filter = 0;
        }
        if($v_MA_TO_CHUYEN_MON_filter == ''){
           $v_MA_TO_CHUYEN_MON_filter = 0;
        }
        return array(
            'hdn_TYPE_filter'   => $v_TYPE_filter,
            'cbx_MA_DON_VI_filter'=> $v_MA_DON_VI_filter,
            'cbx_MA_TO_CHUYEN_MON_filter'=> $v_MA_TO_CHUYEN_MON_filter,
        );
    }
    function dsp_all_luongcanbo(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $arr_filter = $this-> _save_filter();
        $P_TYPE = $arr_filter['hdn_TYPE_filter'];
        if ($P_TYPE == 'MA_DON_VI'){
            $P_MA_DON_VI = $arr_filter['cbx_MA_DON_VI_filter'];
            $VIEW_DATA['arr_filter']       = $arr_filter;
            $VIEW_DATA['arr_all_donvi_filter']       = $this->model->SELECT_DONVI_tatca();
            $VIEW_DATA['arr_all_tochuyenmon_filter'] = $this->model->SELECT_TOCHUYENMON_by_mdv($P_MA_DON_VI);
            $VIEW_DATA['arr_all_canbo']= $this->model->SELECT_HSLCB_BY_MDV_ALL_TR($P_MA_DON_VI);

        }else{
            $P_MA_DON_VI = $arr_filter['cbx_MA_DON_VI_filter'];
            $P_MA_TO_CHUYEN_MON = $arr_filter['cbx_MA_TO_CHUYEN_MON_filter'];
            $VIEW_DATA['arr_filter']       = $arr_filter;
            $VIEW_DATA['arr_all_donvi_filter']       = $this->model->SELECT_DONVI_tatca();
            $VIEW_DATA['arr_all_tochuyenmon_filter'] = $this->model->SELECT_TOCHUYENMON_by_mdv($P_MA_DON_VI);
            $VIEW_DATA['arr_all_canbo']= $this->model->SELECT_HSLCB_BY_MTCM_ALL_TR($P_MA_DON_VI,$P_MA_TO_CHUYEN_MON);
        }
        $this->view->render('dsp_all_luongcanbo', $VIEW_DATA);
    }
    function dsp_all_luongcanbo_to(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $v_m                      = trim(get_request_var('m'));
        $VIEW_DATA['var_matochuyemon'] = $v_m;
        $VIEW_DATA['arr_single_tochuyenmon'] = $this->model->qry_single_tochuyenmon($v_m);
        $VIEW_DATA['arr_all_canbo']        = $this->model->SELECT_HSLCB_BY_MTCM_ALL_TR2($v_m);
        $this->view->render('dsp_all_luongcanbo_to', $VIEW_DATA);
    }
    /****************************form dsp_quatrinhluong_canbo***********************/
     public function dsp_quatrinhluong_canbo($MA_CAN_BO){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_CAN_BO  = replace_bad_char($MA_CAN_BO);
        $TEN_CAN_BO = replace_bad_char($_REQUEST['hdn_item_name']);
        $VIEW_DATA['var_macanbo'] = $MA_CAN_BO;
        $VIEW_DATA['var_tencanbo'] = $TEN_CAN_BO;
        $VIEW_DATA['arr_all_bacngach'] = $this->model->SELECT_BACNGACH_chon();
        $VIEW_DATA['arr_bacngachhientai'] = $this->model->SELECT_BAC_NGACH_HIEN_TAI($MA_CAN_BO);
        $VIEW_DATA['arr_quatrinhtangluong'] = $this->model->SELECT_QUA_TRINH_TANG_LUONG($MA_CAN_BO);
        $this->view->render('dsp_quatrinhluong_canbo', $VIEW_DATA);
    }
    public function capnhat_HSLmoi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_canbo';
        $this->model->capnhat_HSLmoi();
    }
    public function dsp_txt_HSL($P_MA_BAC_NGACH) {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_hesoluong'] = $this->model->SELECT_HSL_BY_MA_BAC_NGACH($P_MA_BAC_NGACH);
        $this->view->render('dsp_txt_HSL', $VIEW_DATA);
    }
    /****************************form dsp_quatrinhPCCV_canbo***********************/
     public function dsp_quatrinhpccv_canbo($MA_CAN_BO){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_CAN_BO  = replace_bad_char($MA_CAN_BO);
        $TEN_CAN_BO = replace_bad_char($_REQUEST['hdn_item_name']);
        $VIEW_DATA['var_macanbo'] = $MA_CAN_BO;
        $VIEW_DATA['var_tencanbo'] = $TEN_CAN_BO;
        $VIEW_DATA['arr_all_phucapchucvu'] = $this->model->SELECT_PHUCAPCHUCVU_chon();
        $VIEW_DATA['arr_pccvhientai'] = $this->model->SELECT_PCCV_HIEN_TAI($MA_CAN_BO);
        $VIEW_DATA['arr_quatrinhpccv'] = $this->model->SELECT_QUA_TRINH_PCCV($MA_CAN_BO);
        $this->view->render('dsp_quatrinhpccv_canbo', $VIEW_DATA);
    }
    public function capnhat_HSPCCVmoi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_canbo';
        $this->model->capnhat_HSPCCVmoi();
    }
    public function dsp_txt_HSPCCV($P_MA_PHU_CAP_CHUC_VU) {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_hesopccv'] = $this->model->SELECT_HSPCCV_BY_MA_PCCV($P_MA_PHU_CAP_CHUC_VU);
        $this->view->render('dsp_txt_HSPCCV', $VIEW_DATA);
    }
    /****************************form dsp_quatrinhPCUD_canbo***********************/
     public function dsp_quatrinhpcud_canbo($MA_CAN_BO){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_CAN_BO  = replace_bad_char($MA_CAN_BO);
        $TEN_CAN_BO = replace_bad_char($_REQUEST['hdn_item_name']);
        $VIEW_DATA['var_macanbo'] = $MA_CAN_BO;
        $VIEW_DATA['var_tencanbo'] = $TEN_CAN_BO;
        $VIEW_DATA['arr_all_phucapuudai'] = $this->model->SELECT_PHUCAPUUDAI_chon();
        $VIEW_DATA['arr_pcudhientai'] = $this->model->SELECT_PCUD_HIEN_TAI($MA_CAN_BO);
        $VIEW_DATA['arr_quatrinhpcud'] = $this->model->SELECT_QUA_TRINH_PCUD($MA_CAN_BO);
        $this->view->render('dsp_quatrinhpcud_canbo', $VIEW_DATA);
    }
    public function capnhat_HSPCUDmoi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_canbo';
        $this->model->capnhat_HSPCUDmoi();
    }
    public function dsp_txt_HSPCUD($P_MA_PHU_CAP_UU_DAI) {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_hesopcud'] = $this->model->SELECT_HSPCTN_BY_MA_PCUD($P_MA_PHU_CAP_UU_DAI);
        $this->view->render('dsp_txt_HSPCUD', $VIEW_DATA);
    }
    /****************************form dsp_quatrinhPCTN_canbo***********************/
     public function dsp_quatrinhpctn_canbo($MA_CAN_BO){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_CAN_BO  = replace_bad_char($MA_CAN_BO);
        $TEN_CAN_BO = replace_bad_char($_REQUEST['hdn_item_name']);
        $VIEW_DATA['var_macanbo'] = $MA_CAN_BO;
        $VIEW_DATA['var_tencanbo'] = $TEN_CAN_BO;
        $VIEW_DATA['arr_all_phucaptrachnhiem'] = $this->model->SELECT_PHUCAPTNHIEM_chon();
        $VIEW_DATA['arr_pctnhientai'] = $this->model->SELECT_PCTN_HIEN_TAI($MA_CAN_BO);
        $VIEW_DATA['arr_quatrinhpctn'] = $this->model->SELECT_QUA_TRINH_PCTN($MA_CAN_BO);
        $this->view->render('dsp_quatrinhpctn_canbo', $VIEW_DATA);
    }
    public function capnhat_HSPCTNmoi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_canbo';
        $this->model->capnhat_HSPCTNmoi();
    }
    public function dsp_txt_HSPCTN($P_MA_PHU_CAP_KHAC) {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_hesopctn'] = $this->model->SELECT_HSPCTN_BY_MA_PCTN($P_MA_PHU_CAP_KHAC);
        $this->view->render('dsp_txt_HSPCTN', $VIEW_DATA);
    }
}
